package com.manager.core.ad.mbactivity

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
//import com.pom3245412.pte9983.nvsd
import com.tencent.mmkv.MMKV
import com.manager.core.master.scope.AdLifecy


abstract class RouteActivity : AppCompatActivity() {

    var routeFrom: String? = null
    var outPageUUid: String? = null

    @SuppressLint("MissingSuperCall")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        bi.GL.d(yyee.llee.mmee.base_api_factory.ModuleConfig.AD_LOG_TAG, "打开了 RouteActivity")

        //修改小米手机6 wifi开关体外弹窗弹两次的问题
        handleFrom()
        yyee.llee.mmee.pl190.host668.otj.JEventTj.onCreateTj(routeFrom, outPageUUid, "create")

        if (!TextUtils.isEmpty(routeFrom) && routeFrom!!.startsWith("timehour:")) {
            MMKV.defaultMMKV().encode("turn_time:lastTime", System.currentTimeMillis());
        }
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        setIntent(intent);
        if (intent != null) {
            handleFrom()
            yyee.llee.mmee.pl190.host668.otj.JEventTj.onCreateTj(routeFrom, outPageUUid, "newintent")
            showAd()
        }
    }

    abstract fun showAd()

    private fun handleFrom() {
        val intent = intent
        if (intent != null) {
            routeFrom = intent.getStringExtra(yyee.llee.mmee.pl190.host668.RouteKey.ROUTE_FROM)
            outPageUUid = intent.getStringExtra(yyee.llee.mmee.pl190.host668.otj.JEventTj.OUTPAGE_KEY)
        }
    }

    open fun addAd(adScope: AdLifecy?): AdLifecy? {
        if (adScope != null) {
            lifecycle.addObserver(adScope)
        }
        return adScope
    }

    open fun mFinish() {
        if (!isFinishing) {
            finish()
        }
    }

    open fun mShowLoading() {}

    open fun mDissLoading() {}
}